﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NetDon.OA.Portal.Components
{
    public partial class MultipleProvinceCity : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.ddlProvince.SelectedValue != string.Empty)
            {
                LoadCities();
            }
            else
            {
                ClearCities();

            }
        }
        public string ProvinceCode
        {
            get { return this.ddlProvince.SelectedValue; }
            set
            {
                this.ddlProvince.SelectedValue = value;
                if (this.ddlProvince.SelectedValue != string.Empty)
                {
                    LoadCities();

                }
                else
                {
                    ClearCities();

                }
            }
        }

        void LoadCities()
        {
            this.ddlCity.LoadDepartments(this.ddlProvince.SelectedValue);
            this.ddlCity1.LoadDepartments(this.ddlProvince.SelectedValue);
            this.ddlCity2.LoadDepartments(this.ddlProvince.SelectedValue);
            this.ddlCity3.LoadDepartments(this.ddlProvince.SelectedValue);
            this.ddlCity4.LoadDepartments(this.ddlProvince.SelectedValue);
        }
        void ClearCities()
        {
            this.ddlCity.Items.Clear();
            this.ddlCity1.Items.Clear();
            this.ddlCity2.Items.Clear();
            this.ddlCity3.Items.Clear();
            this.ddlCity4.Items.Clear();
        }
        public bool EnableCompanyId
        {
            get { return ddlProvince.Enabled; }
            set
            {
                ddlProvince.Enabled = value;
            }
        }
        public bool EnableDepartmentId
        {
            get { return ddlCity.Enabled; }
            set
            {
                ddlCity.Enabled = ddlCity1.Enabled = ddlCity2.Enabled = ddlCity3.Enabled = ddlCity4.Enabled = value;
            }
        }
        public string CityCode
        {
            get { return this.ddlCity.SelectedValue; }
            set
            {
                this.ddlCity.SelectedValue = value;
            }
        }
        public string CityCode1
        {
            get { return this.ddlCity1.SelectedValue; }
            set
            {
                this.ddlCity1.SelectedValue = value;
            }
        }
        public string CityCode2
        {
            get { return this.ddlCity2.SelectedValue; }
            set
            {
                this.ddlCity2.SelectedValue = value;
            }
        }
        public string CityCode3
        {
            get { return this.ddlCity3.SelectedValue; }
            set
            {
                this.ddlCity3.SelectedValue = value;
            }
        }
        public string CityCode4
        {
            get { return this.ddlCity4.SelectedValue; }
            set
            {
                this.ddlCity4.SelectedValue = value;
            }
        }

        public DropDownList ProvinceDropDownList
        {
            get { return ddlProvince; }
        }

        public DropDownList CityDropDownList
        {
            get { return ddlCity; }
        }


        public DropDownList CityDropDownList1
        {
            get { return ddlCity1; }
        }

        public DropDownList CityDropDownList2
        {
            get { return ddlCity2; }
        }

        public DropDownList CityDropDownList3
        {
            get { return ddlCity3; }
        }

        public DropDownList CityDropDownList4
        {
            get { return ddlCity4; }
        }
    }
}